package edu.upenn.pcr.async;

import android.content.Context;
import edu.upenn.pcr.controller.Controller;
import edu.upenn.pcr.controller.DefaultTestingController;
import edu.upenn.pcr.model.async.GetInstructorsAsync;
import edu.upenn.pcr.model.db.PennCourseReviewDBMgr;
import edu.upenn.pcr.model.db.dao.InstructorDAO;
import edu.upenn.pcr.test.AndroidTestCaseBase;

public class GetInstructorAsyncTest extends AndroidTestCaseBase {
	Context context;
	PennCourseReviewDBMgr dbMgr;
	InstructorDAO instrDAO;
	
	@Override
	protected void setUp() throws Exception {
		super.setUp();
		context = this.getTestContext();
		dbMgr = PennCourseReviewDBMgr.getInstance(context);
		instrDAO = dbMgr.getInstructorDAO();
	}
	
	public void testAsync() {
		Controller controller = new DefaultTestingController(context);
		GetInstructorsAsync task = new GetInstructorsAsync(0, controller);
		Long start = System.currentTimeMillis();
		task.test();
		Long end = System.currentTimeMillis();
		System.out.println(".........DONE " + (end-start));
		int count = instrDAO.count();
		assertTrue(count>0);
		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
